package com.lishangshan.oas_system.controller.attendce;

import com.lishangshan.oas_system.model.dao.attendcedao.AttendceDao;
import com.lishangshan.oas_system.model.dao.attendcedao.AttendceService;
import com.lishangshan.oas_system.model.dao.system.StatusDao;
import com.lishangshan.oas_system.model.dao.system.TypeDao;
import com.lishangshan.oas_system.model.dao.user.UserDao;
import com.lishangshan.oas_system.model.dao.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * 周报 表 月报表 控制器
 */
@Controller
@RequestMapping("/")
public class AttendceForWeekController {
    @Autowired
    AttendceDao attenceDao;
    @Autowired
    AttendceService attendceService;
    @Autowired
    UserDao uDao;
    @Autowired
    UserService userService;
    @Autowired
    TypeDao typeDao;
    @Autowired
    StatusDao statusDao;
    // 格式转化导入
    DefaultConversionService service = new DefaultConversionService();
    @Autowired
    private AttendceConFun attendceConFun;
    Date start, end;
    String month_;

    /**
     * 考勤 周报表 初始化控制器
     *
     * @param request
     * @param session
     * @param page
     * @param baseKey
     * @return
     */
    // 考情周报表
    @RequestMapping("attendceweek")
    public String test3(HttpServletRequest request, HttpSession session,
                        @RequestParam(value = "page", defaultValue = "0") int page,
                        @RequestParam(value = "baseKey", required = false) String baseKey) {
        attendceConFun.weektablepaging(request, session, page, baseKey);
        return "attendce/weektable";
    }

    /**
     * 当前 周表报 等同于 上一月，下一月
     *
     * @param request
     * @param session
     * @param page
     * @param baseKey
     * @return
     */
    //当前考勤周报表
    @RequestMapping("realweektable")
    public String dsaf(HttpServletRequest request, HttpSession session,
                       @RequestParam(value = "page", defaultValue = "0") int page,
                       @RequestParam(value = "baseKey", required = false) String baseKey) {
        attendceConFun.weektablepaging(request, session, page, baseKey);
        return "attendce/realweektable";

    }

    /**
     * 考勤 月报表 初始化
     *
     * @param request
     * @param model
     * @param session
     * @param page
     * @param baseKey
     * @return
     */
    // 考勤月报表
    @RequestMapping("attendcemonth")
    public String test2(HttpServletRequest request, Model model, HttpSession session,
                        @RequestParam(value = "page", defaultValue = "0") int page,
                        @RequestParam(value = "baseKey", required = false) String baseKey) {
        attendceConFun.monthtablepaging(request, model, session, page, baseKey);
        return "attendce/monthtable";
    }

    /**
     * 当前 周表报 等同于 上一周 下一周
     *
     * @param request
     * @param model
     * @param session
     * @param page
     * @param baseKey
     * @return
     */
    //当前考勤月报表
    @RequestMapping("realmonthtable")
    public String dfshe(HttpServletRequest request, Model model, HttpSession session,
                        @RequestParam(value = "page", defaultValue = "0") int page,
                        @RequestParam(value = "baseKey", required = false) String baseKey) {
        attendceConFun.monthtablepaging(request, model, session, page, baseKey);
        return "attendce/realmonthtable";
    }
}
